﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Blabber.Client"
    x:Class="Blabber.Client.WindowMain"
    Title="Blabber" Height="700" Width="225" MinWidth="225" MinHeight="300" 
    Closed="OnWindowClosed" WindowStartupLocation="Manual">

    <Window.Resources>
        <Style x:Key="titleStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="FontSize" Value="18" />
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="FontStretch" Value="Normal"/>
            <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
        </Style>

        <Style x:Key="rosterItemStyle" TargetType="ListBoxItem">
            <Setter Property="Foreground" Value="Black"></Setter>
            
            <Style.Triggers>
                <Trigger Property="ListBoxItem.IsSelected" Value="True">
                    <Setter Property="ListBoxItem.Foreground" Value="Black" />
                    <Setter Property="ListBoxItem.Background" Value="#FFDAD6D6" />
                </Trigger>

                <DataTrigger Binding="{Binding Path=Show}" Value="NONE">
                    <Setter Property="ListBoxItem.Foreground" Value="Blue"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding Path=Show}" Value="away">
                    <Setter Property="ListBoxItem.Foreground" Value="Red"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding Path=Show}" Value="dnd">
                    <Setter Property="ListBoxItem.Foreground" Value="Green"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding Path=IsAvailable}" Value="False">
                    <Setter Property="ListBoxItem.Foreground" Value="LightGray" />
                </DataTrigger>


            </Style.Triggers>
        </Style>

        <local:ShowValueConverter x:Key="showValueConverter" />
        <local:PictureValueConverter x:Key="pictureValueConverter" />

        <DataTemplate x:Key="DataTemplateRosterItem">
        	<DataTemplate.Resources>
        		<Storyboard x:Key="OnMouseEnter1">
        			<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="mainBorder" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
        				<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
        				<SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFCFCFCF"/>
        			</ColorAnimationUsingKeyFrames>
        			
        		</Storyboard>
        		<Storyboard x:Key="TimelineMouseExit">
        			<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="mainBorder">
        				<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFCFCFCF"/>
        				<SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFFFFFF"/>
        			</ColorAnimationUsingKeyFrames>
        			
        		</Storyboard>
        	</DataTemplate.Resources>
            <Grid Margin="3,3,3,3" Width="Auto" HorizontalAlignment="Stretch" x:Name="grid">
                <Border Name="mainBorder" Height="Auto" BorderBrush="#FF000000" 
                BorderThickness="1,1,1,1" CornerRadius="4,4,4,4" HorizontalAlignment="Stretch" Width="Auto" Background="#FFFFFFFF" >
                    <Grid Margin="3" x:Name="grid1" Background="{x:Null}">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />    
                        </Grid.ColumnDefinitions>

                        <Image HorizontalAlignment="Right" Height="32" Width="32" Stretch="Uniform" Grid.RowSpan="2" Grid.Column="1" Margin="2"
                            Source="{Binding Path=Image, Converter={StaticResource pictureValueConverter}}" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" x:Name="image" Panel.ZIndex="2" >
                        	<Image.BitmapEffect>
                        		<DropShadowBitmapEffect/>
                        	</Image.BitmapEffect>
                        	<Image.RenderTransform>
                        		<TransformGroup>
                        			<ScaleTransform ScaleX="1" ScaleY="1"/>
                        			<SkewTransform AngleX="0" AngleY="0"/>
                        			<RotateTransform Angle="0"/>
                        			<TranslateTransform X="0" Y="0"/>
                        		</TransformGroup>
                        	</Image.RenderTransform>
                        </Image>
                        
                        
                        <TextBlock Grid.Column="1" Width="Auto" Grid.Row="0" Text="{Binding Name}" TextWrapping="Wrap" FontSize="15" Style="{DynamicResource titleStyle}" VerticalAlignment="Top"/>
                        <TextBlock Grid.Column="1" Width ="Auto" Name="JIDTextBlock" Grid.Row="1" Text="{Binding JID}" TextWrapping="Wrap" FontSize="11" VerticalAlignment="Top"/>
                    </Grid>
                </Border>
            </Grid>
        	<DataTemplate.Triggers>
        		<Trigger Property="IsMouseOver" SourceName="mainBorder" Value="True">
        			<Trigger.EnterActions>
        				<BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}"/>
        			</Trigger.EnterActions>
        			<Trigger.ExitActions>
        				<BeginStoryboard x:Name="TimelineMouseExit_BeginStoryboard" Storyboard="{StaticResource TimelineMouseExit}"/>
        			</Trigger.ExitActions>
        		</Trigger>
        	</DataTemplate.Triggers>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

		<Menu Grid.Row="0" Grid.Column="0">
			<MenuItem Header="Settings" Click="MenuItem_Click" />
			<!--<MenuItem Header="Community" Click="Community_Click" />-->
			<MenuItem Header="Sign Out" Name="menuItemSignInOut" Click="MenuItemSignOut_Click" />
		</Menu>
		
		<Grid Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition></ColumnDefinition>
			</Grid.ColumnDefinitions>
			
			<ComboBox Name="comboBoxStatus" IsEditable="False" Grid.Column="0" VerticalAlignment="Center" Margin="3" SelectedIndex="0"
				ItemsSource="{Binding}" DisplayMemberPath="Name" SelectionChanged="statusChangedEvent">
			</ComboBox>
		</Grid>

		<Grid Grid.Row="2" Grid.Column="0">

            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>

            <ListBox Name="rosterListBox" HorizontalContentAlignment="Stretch" 
               ItemsSource="{Binding}" ItemContainerStyle="{StaticResource rosterItemStyle}"
               ItemTemplate="{DynamicResource DataTemplateRosterItem}" OverridesDefaultStyle="False" ScrollViewer.CanContentScroll="False"
                     MouseDoubleClick="rosterListBox_MouseDoubleClick">
                <ListBox.Resources>
                	<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFFFFFFF"/>
                </ListBox.Resources>
            </ListBox>
        </Grid>
    </Grid>
</Window>
